/**
* @file nav_struct.h in loosely_couple_h7
* @author rebeater
* @comment
* Create on 2021/1/24 下午5:53
* @version 1.0
**/

//
// Created by rebeater on 2021/1/24.
//

#ifndef LOOSELY_COUPLE_H7_NAV_STRUCT_H
#define LOOSELY_COUPLE_H7_NAV_STRUCT_H

#include <cstdint>
typedef struct {
    int32_t gyro[3]; /* 4 * 3*/
    int32_t acce[3]; /* 4 * 3*/

    double time_s;
} ImuRawStim;

#define _PI 3.1415926535897932
#define _hour 3600
#define _minute 60
#define _sqrt_h 60
#define _deg (_PI/180.0)
#define _mGal (1e-5)
#define _ppm (1e-6)

typedef struct {
    uint16_t stat;/*STAT_OUT*/
    int16_t gyro[3];
    int16_t acce[3];
    int16_t temp;/*TEMP_OUT*/
    uint16_t cnt;/*SMPL_CNTR*/
    uint16_t checksum;
    uint32_t reserved;
    double time_s;
} ImuRawAdi; /*size of ADI=2+2*3+2*3+2+2+2+8 =32 bytes*/
typedef struct {
    double gpst;
    double reserved;
    int16_t gyro[3];
    int16_t acce[3];
} ImuRawIcm;
typedef struct {
    double gpst;
    double gyro[3];
    double acce[3];
} ImuData;

typedef enum{
    UNVALID = -1,
    INITIAL = 0,
    SPP = 1,
    RTK_DGPS = 2,
    UNKNOWN_PPS = 3,
    RTK_FIX = 4,
    RTK_FLOAT = 5,
} GnssMode;
typedef struct {
    double gpst;
    double lat;
    double lon;
    double height;
    float pos_std[3];
    float hdop;
    int ns;
    unsigned int mode;/*enum GnssMode体积是1，因此作为结构体很不方便*/
    int week;
    int reserved;
} GnssData;/*64 bytes*/

typedef struct {

    double arw;
    double vrw;
    double ab_ini[3];
    double gb_ini[3];
    double as_ini[3];
    double gs_ini[3];
    double ab_std;
    double gb_std;
    double gs_std;
    double as_std;
    double at_corr;
    double gt_corr;
} ImuPara;
typedef enum {
    IMU_FORMAT_IMD = 0,
    IMU_FORMAT_IMUTXT = 1
} ImuFileFormat;
typedef enum {
    GNSS_TXT_POS_7 = 0,
    GNSS_BIN_POS_7 = 1,
    GNSS_TXT_POS_14 = 2,
    GNSS_BIN_POS_14 = 3,
    RTKLIB_TXT_POS = 4,
    GNSS_TXT_POS_VEL = 5,
    GNSS_TXT_GGA = 6,
    RESERVED = 6,
} GnssFileFormat;

typedef struct {
    double gpst;
    double pos[3];
    float vn[3];
    float atti[3];
    GnssMode mode;
} NavOutput;

typedef struct {
    double latitude;
    double longitude;
} LatLon;
typedef struct  {
    double gpst;
    double lat;
    double lon;
    double h;
    double vn;
    double ve;
    double vd;
    double roll;
    double pitch;
    double yaw;
    double ab[3];
    double gb[3];
/*    double pos_std_[3];
    double vel_std_[3];
    double atti_std_[3];*/
    long mode;
}NavEpoch;
typedef enum  {
    UseGiven = 0,
    Moving = 1,
    Static = 2
}AlignMode ;

typedef struct {
    ImuPara imuPara;
    int imu_data_rate;
    AlignMode align_mode;
    NavEpoch init_epoch;
    int nhc_enable;
    float nhc_var;
    int zupt_enable;
    float zupt_var ;
    float zupta_var ;
    float antenna_arm[3];
    int odo_enable;
    float odo_var;
    float odo_wheel_radius;
} Option;
typedef struct {
    float forward;
    float angular;
    double time_s;
} Velocity;

/**
 * CameraInfo from Uart
 */
typedef  struct  {
  unsigned int Header; /*4*/
  char ImageName[24]; /*24*/
  float Vn[3];/*4*3 = 12*/
  float VnStd[3];/*12*/
  unsigned int crc;/*4*/
}CameraInfo;

typedef struct {
  CameraInfo camera_info_;
  double time_s;
}CameraEvent;
#endif //LOOSELY_COUPLE_H7_NAV_STRUCT_H
